package com.netease.pris.provider;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import com.netease.pris.protocol.c;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;

public class ac extends SQLiteOpenHelper
{
  static final String a = "SQLiteOpenHelperEx";
  private static ac b = null;

  public ac(Context paramContext)
  {
    this(paramContext, "pris.db", null, 10);
  }

  private ac(Context paramContext, String paramString, SQLiteDatabase.CursorFactory paramCursorFactory, int paramInt)
  {
    super(paramContext, paramString, paramCursorFactory, paramInt);
  }

  private void A(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("ALTER TABLE account ADD refresh INTEGER DEFAULT 0");
  }

  private void B(SQLiteDatabase paramSQLiteDatabase)
  {
    String[] arrayOfString1 = new String[9];
    arrayOfString1[0] = "account";
    arrayOfString1[1] = "name";
    arrayOfString1[2] = "last_login";
    arrayOfString1[3] = "type_weibo";
    arrayOfString1[4] = "other";
    arrayOfString1[5] = "token_weibo";
    arrayOfString1[6] = "secret_weibo";
    arrayOfString1[7] = "main_url";
    arrayOfString1[8] = "portrait_url";
    Cursor localCursor1 = paramSQLiteDatabase.query("weibo_account", arrayOfString1, null, null, null, null, null);
    if (localCursor1 != null)
    {
      HashMap localHashMap = new HashMap();
      if (localCursor1.moveToFirst())
        do
        {
          ContentValues localContentValues3 = new ContentValues();
          a(localContentValues3, localCursor1, "account", 0);
          a(localContentValues3, localCursor1, "name", 1);
          localContentValues3.put("last_login", Long.valueOf(localCursor1.getLong(2)));
          int i = localCursor1.getInt(3);
          localContentValues3.put("type_weibo", Integer.valueOf(i));
          a(localContentValues3, localCursor1, "other", 4);
          a(localContentValues3, localCursor1, "token_weibo", 5);
          a(localContentValues3, localCursor1, "secret_weibo", 6);
          a(localContentValues3, localCursor1, "main_url", 7);
          a(localContentValues3, localCursor1, "portrait_url", 8);
          LinkedList localLinkedList3 = (LinkedList)localHashMap.get(Integer.valueOf(i));
          if (localLinkedList3 == null)
          {
            localLinkedList3 = new LinkedList();
            localHashMap.put(Integer.valueOf(i), localLinkedList3);
          }
          localLinkedList3.add(localContentValues3);
        }
        while (localCursor1.moveToNext());
      localCursor1.close();
      if (localHashMap.size() > 0)
      {
        String[] arrayOfString2 = new String[1];
        arrayOfString2[0] = "name";
        Cursor localCursor2 = paramSQLiteDatabase.query("account", arrayOfString2, null, null, null, null, null);
        if (localCursor2 != null)
        {
          LinkedList localLinkedList1 = new LinkedList();
          if (localCursor2.moveToFirst())
          {
            do
            {
              String str2 = localCursor2.getString(0);
              if (str2 == null)
                continue;
              localLinkedList1.add(str2);
            }
            while (localCursor2.moveToNext());
            localCursor2.close();
          }
          if (!localLinkedList1.contains(c.b))
            localLinkedList1.add(c.b);
          Iterator localIterator1 = localHashMap.values().iterator();
          while (localIterator1.hasNext())
          {
            LinkedList localLinkedList2 = (LinkedList)localIterator1.next();
            ContentValues localContentValues1 = (ContentValues)localLinkedList2.getFirst();
            Iterator localIterator2 = localLinkedList1.iterator();
            while (localIterator2.hasNext())
            {
              String str1 = (String)localIterator2.next();
              if (a(localLinkedList2, str1))
                continue;
              ContentValues localContentValues2 = new ContentValues(localContentValues1);
              localContentValues2.put("account", str1);
              paramSQLiteDatabase.insert("weibo_account", null, localContentValues2);
            }
          }
        }
      }
    }
  }

  public static ac a(Context paramContext)
  {
    if (b == null)
      b = new ac(paramContext);
    return b;
  }

  private void a(ContentValues paramContentValues, Cursor paramCursor, String paramString, int paramInt)
  {
    String str = paramCursor.getString(paramInt);
    if (str != null)
      paramContentValues.put(paramString, str);
  }

  private boolean a(LinkedList paramLinkedList, String paramString)
  {
    Iterator localIterator = paramLinkedList.iterator();
    do
      if (!localIterator.hasNext())
        break;
    while (!paramString.equals(((ContentValues)localIterator.next()).getAsString("account")));
    for (int i = 1; ; i = 0)
      return i;
  }

  private void q(SQLiteDatabase paramSQLiteDatabase)
  {
    B(paramSQLiteDatabase);
  }

  private void r(SQLiteDatabase paramSQLiteDatabase)
  {
    A(paramSQLiteDatabase);
    paramSQLiteDatabase.execSQL(" drop table if exists fonts");
    f(paramSQLiteDatabase);
  }

  private void s(SQLiteDatabase paramSQLiteDatabase)
  {
    z(paramSQLiteDatabase);
  }

  private void t(SQLiteDatabase paramSQLiteDatabase)
  {
    y(paramSQLiteDatabase);
  }

  private void u(SQLiteDatabase paramSQLiteDatabase)
  {
    x(paramSQLiteDatabase);
  }

  private void v(SQLiteDatabase paramSQLiteDatabase)
  {
    w(paramSQLiteDatabase);
    onCreate(paramSQLiteDatabase);
  }

  private void w(SQLiteDatabase paramSQLiteDatabase)
  {
    try
    {
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "account");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "weibo_account");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "subscribe");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "cachetabable");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "favorite");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "config");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "search");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "conver");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "article_status");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "offline");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "fonts");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "temp_subcribe");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "temp_article");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "temp_comment");
      paramSQLiteDatabase.execSQL(" drop table if exists  " + "temp_search");
      return;
    }
    catch (SQLiteException localSQLiteException)
    {
      while (true)
        localSQLiteException.printStackTrace();
    }
  }

  private void x(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" UPDATE subscribe SET seq = _id");
  }

  private void y(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("ALTER TABLE subscribe ADD refresh INTEGER DEFAULT 0");
  }

  private void z(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" ALTER TABLE offline RENAME TO offline_tmp; ");
    paramSQLiteDatabase.execSQL(" CREATE TABLE offline ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL, other TEXT, UNIQUE (uid, account) ON CONFLICT REPLACE );");
    paramSQLiteDatabase.execSQL(" INSERT INTO offline SELECT _id, account, uid, other FROM offline_tmp; ");
    paramSQLiteDatabase.execSQL(" DROP TABLE offline_tmp; ");
  }

  void a(SQLiteDatabase paramSQLiteDatabase)
  {
    b(paramSQLiteDatabase);
    c(paramSQLiteDatabase);
    d(paramSQLiteDatabase);
    g(paramSQLiteDatabase);
    h(paramSQLiteDatabase);
    i(paramSQLiteDatabase);
    j(paramSQLiteDatabase);
    k(paramSQLiteDatabase);
    l(paramSQLiteDatabase);
    e(paramSQLiteDatabase);
    f(paramSQLiteDatabase);
    m(paramSQLiteDatabase);
    n(paramSQLiteDatabase);
    o(paramSQLiteDatabase);
    p(paramSQLiteDatabase);
  }

  void b(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE account ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, password TEXT NOT NULL,last_login INTEGER, auot_login BOOL default true,main INTEGER default 0,other TEXT,first_login INTEGER default 0,refresh INTEGER default 0, UNIQUE (name) ON CONFLICT REPLACE ) ");
  }

  void c(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE weibo_account ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, name TEXT NOT NULL, last_login INTEGER, type_weibo INTEGER, token_weibo TEXT, secret_weibo TEXT, main_url TEXT, portrait_url TEXT, other TEXT, UNIQUE (name , account , type_weibo) ON CONFLICT REPLACE ) ");
  }

  void d(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE subscribe ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL,updated TEXT,title TEXT,type INTEGER DEFAULT 1 ,content TEXT , seq INTEGER , other TEXT ,refresh INTEGER DEFAULT 0 , UNIQUE (uid,account) ON CONFLICT REPLACE ) ");
  }

  void e(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE offline ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL,other TEXT, UNIQUE (uid, account) ON CONFLICT REPLACE ) ");
  }

  void f(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE fonts ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, url TEXT NOT NULL,desc TEXT,len INTEGER default 0,md TEXT,path TEXT,state INTEGER default 0, UNIQUE (name) ON CONFLICT IGNORE ) ");
  }

  void g(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE favorite ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL,updated TEXT,title TEXT,timestamp INTEGER,other TEXT,file TEXT,type TEXT, UNIQUE (uid,account) ON CONFLICT REPLACE ) ");
  }

  void h(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("CREATE TABLE cachetabable (_id INTEGER PRIMARY KEY, account TEXT, url TEXT, filepath TEXT, lastmodify TEXT, etag TEXT, expires INTEGER, expiresstring TEXT, encoding TEXT,contentlength INTEGER, timestamp INTEGER,data1 TEXT, UNIQUE (url) ON CONFLICT REPLACE);");
  }

  void i(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("CREATE TABLE config(_id INTEGER PRIMARY KEY AUTOINCREMENT,group_name TEXT not null,name TEXT not null,value TEXT,type INTEGER default 2 ,UNIQUE (name,group_name ) ON CONFLICT REPLACE)");
  }

  void j(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE search(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,content TEXT NOT NULL,timestamp INTEGER,other TEXT,UNIQUE ( account,content ) ON CONFLICT REPLACE)");
  }

  void k(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE article_status ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT, uid TEXT NOT NULL,status INTEGER,timestamp INTEGER,other TEXT,UNIQUE ( account,uid ) ON CONFLICT REPLACE ) ");
    paramSQLiteDatabase.execSQL(" CREATE TRIGGER max_size_trigger  AFTER INSERT  ON article_status WHEN (SELECT COUNT(*) FROM article_status )  > 1000 BEGIN  DELETE FROM article_status WHERE timestamp <=  0.1 * (SELECT MAX(timestamp)  FROM article_status)  + 0.9 * (SELECT MIN(timestamp)  FROM article_status) ; END; ");
  }

  void l(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" create table conver(_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT not null,updated TEXT,type TEXT ,flag INTEGER default 0,image TEXT ,path TEXT ,thumn_image TEXT ,thumb_path TEXT ,other TEXT )");
  }

  void m(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE temp_subcribe(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT, subcribable INTEGER default 0,subcribed INTEGER default 0,rank INTEGER default 0,type INTEGER ,content TEXT ,other TEXT ,UNIQUE ( account,uid ) ON CONFLICT REPLACE)");
  }

  void n(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE temp_comment(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT ,user TEXT ,content TEXT, article_uid TEXT ,other TEXT ,UNIQUE ( account,uid,article_uid ) ON CONFLICT REPLACE)");
  }

  void o(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE temp_article(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT ,favorite INTEGER default 0,file TEXT , stream TEXT,content TEXT, other TEXT, UNIQUE ( account,uid ) ON CONFLICT REPLACE)");
  }

  public void onCreate(SQLiteDatabase paramSQLiteDatabase)
  {
    a(paramSQLiteDatabase);
  }

  public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
  {
    if (paramInt1 == paramInt2);
    while (true)
    {
      return;
      if (paramInt1 > paramInt2)
      {
        v(paramSQLiteDatabase);
        continue;
      }
      if (paramInt1 < 5)
      {
        v(paramSQLiteDatabase);
        continue;
      }
      switch (paramInt1)
      {
      default:
        break;
      case 5:
        u(paramSQLiteDatabase);
      case 6:
        t(paramSQLiteDatabase);
      case 7:
        s(paramSQLiteDatabase);
      case 8:
        r(paramSQLiteDatabase);
      case 9:
        q(paramSQLiteDatabase);
      }
    }
  }

  void p(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL(" CREATE TABLE temp_search(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT ,subcribable INTEGER default 0,subcribed INTEGER default 0,rank INTEGER default 0,content TEXT ,other TEXT ,UNIQUE ( account,uid ) ON CONFLICT REPLACE)");
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.provider.ac
 * JD-Core Version:    0.6.0
 */